#include "main/utils.h"
using namespace std;

class Solution {
public:
    vector<vector<int>> construct2DArray(vector<int>& original, int m, int n) {
      vector<vector<int>> ret;
      int size = original.size();
      if (size != m * n)
        return ret;

      ret.resize(m);
      for (int i = 0; i < m; ++i)
        ret[i].resize(n);

      int k = 0;
      for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
          ret[i][j] = original[k++];
        }
      }
      return ret;
    }
};

int main() {
  vector<int> nums = {1, 2, 3, 4};
  int m = 2, n = 2;
  Solution su;
  auto ret = su.construct2DArray(nums, m, n);
  printVec("leetcode2022", ret);

  return 0;
}
